﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Configuration;

namespace DonationTracker.Account.Admin
{
    public partial class AssignEvent : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
                //if (User.Identity.IsAuthenticated)
                //{
                //    string userID = Membership.GetUser().ProviderUserKey.ToString();
                //    string connstring = ConfigurationManager.ConnectionStrings["DonationConn"].ToString();
                //    string sql = "SELECT DonationNumber, donorID, Description, DateEntered, aspnet_users.UserName AS EnteredBy FROM Donation INNER JOIN aspnet_users ON Donation.EnteredBy = aspnet_users.UserId WHERE assigned = 0 AND charityID = '" + ddlCharity.SelectedValue + "'";
                //    //string updateSql = "UPDATE Donation SET EventID = '" + + "' WHERE DonationID = " + ;
                //    dsAssignEventGrid.ConnectionString = connstring;
                //    dsAssignEventGrid.SelectCommand = sql;
                //    gvAssignEvent.DataSource = dsAssignEventGrid;
                //    gvAssignEvent.DataBind();

                //    string connstring2 = ConfigurationManager.ConnectionStrings["DonationConn"].ToString();
                //    string assignedSql = "SELECT DonationNumber, donorID, Donation.Description, event.name AS EventName, DateEntered, aspnet_users.UserName AS EnteredBy FROM Donation INNER JOIN event ON Donation.eventID = event.eventID INNER JOIN aspnet_users ON Donation.EnteredBy = aspnet_users.UserId WHERE assigned = 1 AND donation.charityID = '" + ddlCharity.SelectedValue + "'";
                //    dsEventsAssignedGrid.ConnectionString = connstring2;
                //    dsEventsAssignedGrid.SelectCommand = assignedSql;
                //    gvAssignedEvents.DataSource = dsEventsAssignedGrid;
                //    gvAssignedEvents.DataBind();
             
                //}
           
        }

        protected void gvAssignEvent_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            DropDownList ddlEvent =
                (DropDownList)gvAssignEvent.Rows[e.RowIndex].FindControl("ddlEvent");

            dsAssignEventGrid.UpdateParameters["eventID"] =
                new Parameter("eventID", System.Data.DbType.Int32, ddlEvent.SelectedValue);

          

            
        }
    } 
}